package com.lxj.controller;

import com.lxj.domain.User;
import com.lxj.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ResponseBody
@Controller
@RequestMapping(path = "/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/findAll")
    public Map<String,Object> findAll(User user){
        List<User> list = userService.findAll(user);
        int number = userService.getCount();
        Map<String,Object> map = new HashMap<>();
        map.put("list",list);
        map.put("number",number);
        return map;
    }
    @GetMapping("/delete")
    public int delete(Integer[] id){
        System.out.println(id);
        return userService.delete(id);
    }
    @PostMapping("/findByUserName")
    public User findByUserName(User user){
        return userService.findByUserName(user);
    }
    @PostMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }
    @PostMapping("/edit")
    public int edit(User user){
        return userService.edit(user);
    }
    @PostMapping("/findNoGroupUser")
    public List<User> findNoGroupUser(){
        return userService.findNoGroupUser();
    }
//    @PostMapping("/edit")
//    public int edit(User user){
//
//    }
    @PostMapping("/editPassword")
    public int editPassword(User user){
        return userService.editPassword(user);
    }
}
